#include "conf.h"

int *video_quality = &conf.video_quality;
int *video_mode    = &conf.video_mode;

long def_table1[9]={0x2000,0x38D,0x788,0x5800,0x9C5,0x14B8,0x10000,0x1C6A,0x3C45};
long def_table2[9]={0x1CCD,-0x2E1,-0x579,0x4F33,-0x7EB,-0xF0C,0xE666,-0x170A,-0x2BC6};

long table1[9], table2[9];

void change_video_tables(int a, int b){
 int i;
 for (i=0;i<9;i++) {table1[i]=(def_table1[i]*a)/b; table2[i]=(def_table2[i]*a)/b;}
}

long CompressionRateTable[]={0x60, 0x5D, 0x5A, 0x57, 0x54, 0x51, 0x4D, 0x48, 0x42, 0x3B, 0x32, 0x29, 0x22, 0x1D, 0x17, 0x14, 0x10, 0xE, 0xB, 9, 7, 6, 5, 4, 3, 2, 1};

void __attribute__((naked,noinline)) movie_record_task(){
	asm volatile(
		"STMFD   SP!, {R4,LR}\n"
		"SUB     SP, SP, #4\n"
		"MOV     R4, SP\n"
		"B       sub_FFD2A3DC\n"
	"sub_FFD2A338:\n"
		"LDR     R3, =0x646E8\n"
		"LDR     R2, [R3]\n"
		"CMP     R2, #0\n"
		"BNE     sub_FFD2A3C8\n"
		"SUB     R3, R12, #2\n"
		"CMP     R3, #9\n"
		"LDRLS   PC, [PC,R3,LSL#2]\n"
		"B       sub_FFD2A3C8\n"
		".long sub_FFD2A388\n"
		".long sub_FFD2A3A0\n"
		".long sub_FFD2A3A8\n"
		".long sub_FFD2A3B0\n"
		".long sub_FFD2A390\n"
		".long sub_FFD2A3B8\n"
		".long sub_FFD2A398\n"
		".long sub_FFD2A3C8\n"
		".long sub_FFD2A3C0\n"
		".long sub_FFD2A380\n"
	"sub_FFD2A380:\n"
		"BL      sub_FFD2A474\n"
		"B       sub_FFD2A3C4\n"
	"sub_FFD2A388:\n"
	        "BL      unlock_optical_zoom\n"
		"BL      sub_FFD2A628\n"
		"B       sub_FFD2A3C4\n"
	"sub_FFD2A390:\n"
        //        "BL      sub_FFD2A9FC\n"
		"BL      sub_FFD2A9FC_my\n"//--------------->    
		"B       sub_FFD2A3C4\n"
	"sub_FFD2A398:\n"
		"BL      sub_FFD2AE30\n"
		"B       sub_FFD2A3C4\n"
	"sub_FFD2A3A0:\n"
		"BL      sub_FFD2AC94\n"
		"B       sub_FFD2A3C4\n"
	"sub_FFD2A3A8:\n"
		"BL      sub_FFD2AFA0\n"
		"B       sub_FFD2A3C4\n"
	"sub_FFD2A3B0:\n"
		"BL      sub_FFD2B164\n"
		"B       sub_FFD2A3C4\n"
	"sub_FFD2A3B8:\n"
		"BL      sub_FFD2AEB8\n"
		"B       sub_FFD2A3C4\n"
	"sub_FFD2A3C0:\n"
		"BL      sub_FFD2ACE4\n"
	"sub_FFD2A3C4:\n"
		"LDR     R1, [SP,#0xC-0xC]\n"
	"sub_FFD2A3C8:\n"
		"LDR     R3, =0x6461C\n"
		"MOV     R2, #0\n"
		"STR     R2, [R1]\n"
		"LDR     R0, [R3]\n"
		"BL      sub_FFC104D8\n"
	"sub_FFD2A3DC:\n"
		"LDR     R3, =0x64618\n"
		"MOV     R1, R4\n"
		"LDR     R0, [R3]\n"
		"MOV     R2, #0\n"
		"BL      sub_FFC100C0\n"
		"LDR     R0, [SP,#0xC-0xC]\n"
		"LDR     R12, [R0]\n"
		"CMP     R12, #0xC\n"
		"MOV     R1, R0\n"
		"BNE     sub_FFD2A338\n"
		"LDR     R3, =0x64614\n"
		"LDR     R0, [R3]\n"
		"BL      sub_FFC10E54\n"
		"BL      sub_FFC1161C\n"
		"ADD     SP, SP, #4\n"
		"LDMFD   SP!, {R4,PC}\n"
	);
}






void __attribute__((naked,noinline)) sub_FFD2A9FC_my(){
	asm volatile(
		"STMFD   SP!, {R4-R11,LR}\n"
                "LDR     R5, =0x64704\n"
                "SUB     SP, SP, #0x34\n"
                "LDR     R3, [R5]\n"
                "CMP     R3, #3\n"
                "MOV     R4, R0\n"
                "MOVEQ   R3, #4\n"
                "STREQ   R3, [R5]\n"
                "LDR     R3, =0x647B4\n"
                "MOV     LR, PC\n"
                "LDR     PC, [R3]\n"
                "LDR     R2, [R5]\n"
                "CMP     R2, #4\n"
                "BNE     sub_FFD2ABC0\n"
                "ADD     R0, SP, #0x30\n"
                "ADD     R1, SP, #0x2C\n"
                "ADD     R2, SP, #0x28\n"
                "ADD     R3, SP, #0x24\n"
           //     "BL      sub_FFD2C0D0\n"
                "BL      sub_FFD2C0D0_my\n"   //--------------------->
                "CMP     R0, #0\n"
                "BNE     sub_FFD2AA78\n"
                "LDR     R3, =0x646F0\n"
                "LDR     R2, [R3]\n"
                "CMP     R2, #1\n"
                "BNE     sub_FFD2AA8C\n"
                "LDR     R2, =0x64748\n"
                "LDR     R1, =0x6471C\n"
                "LDR     R12, [R2]\n"
                "LDR     R3, [R1]\n"
                "CMP     R12, R3\n"
                "BCC     sub_FFD2AA8C\n"
	"sub_FFD2AA78:\n"
                "BL      sub_FFD2AC0C\n"
                "BL      sub_FFD2AE0C\n"
                "MOV     R3, #5\n"
                "STR     R3, [R5]\n"
                "B       sub_FFD2ABC0\n"

	"sub_FFD2AA8C:\n"
                "LDR     R12, =0x64750\n"
                "LDR     R11, =0x6475C\n"
                "LDMIB   R4, {R0-R2}\n"
                "LDR     R10, [R12]\n"
                "LDR     R7, [R11]\n"
                "LDR     R4, [SP,#0x2C]\n"
                "LDR     R5, [SP,#0x28]\n"
                "LDR     R6, [SP,#0x24]\n"
                "LDR     R8, =0x646F4\n"
                "LDR     R3, [SP,#0x30]\n"
                "ADD     R12, SP, #0x20\n"
                "ADD     LR, SP, #0x1C\n"
                "MOV     R9, #1\n"
                "STMEA   SP, {R4-R6,R12}\n"
                "STR     R10, [SP,#0x10]\n"
                "STR     R7, [SP,#0x14]\n"
                "STR     LR, [SP,#0x18]\n"
                "STR     R9, [R8]\n"
                "BL      sub_FFC84D30\n"
                "LDR     R3, =0x6460C\n"
                "MOV     R1, #0x3E8\n"
                "LDR     R0, [R3]\n"
                "BL      sub_FFC10C6C\n"
                "CMP     R0, #9\n"
                "BNE     sub_FFD2AB00\n"
                "BL      sub_FFD2C8E0\n"
                "LDR     R3, =0x64704\n"
                "LDR     R0, =0xFFD2A9E4\n"
                "B       sub_FFD2AB18\n"
	"sub_FFD2AB00:\n"
                "LDR     R5, [SP,#0x1C]\n"
                "CMP     R5, #0\n"
                "BEQ     sub_FFD2AB24\n"
                "BL      sub_FFD2C8E0\n"
                "LDR     R3, =0x64704\n"
                "LDR     R0, =0xFFD2A9F0\n"
	"sub_FFD2AB18:\n"
                "STR     R9, [R3]\n"
                "BL      sub_FFD3F860\n"
                "B       sub_FFD2ABC0\n"
	"sub_FFD2AB24:\n"
                "BL      sub_FFC84E9C\n"
                "LDR     R0, [SP,#0x30]\n"
                "LDR     R1, [SP,#0x20]\n"
                "BL      sub_FFD2C604\n"
                "LDR     R4, =0x64748\n"
                "LDR     R3, [R4]\n"
                "ADD     R3, R3, #1\n"
                "LDR     R0, [SP,#0x20]\n"
                "MOV     R1, R11\n"
                "STR     R3, [R4]\n"
                "MOV     R2, R5\n"
         //       "BL      sub_FFD2B4C0\n"
                "BL      sub_FFD2B4C0_my\n"    //---------------------->
                "LDR     R3, =0x64768\n"
                "LDR     R1, [R4]\n"
                "LDR     R2, [R3]\n"
                "LDR     R12, =0x64764\n"
                "MUL     R0, R2, R1\n"
                "LDR     R1, [R12]\n"
                "BL      sub_FFEBF164\n"
                "LDR     R7, =0x64760\n"
                "LDR     R3, [R7]\n"
                "MOV     R4, R0\n"
                "CMP     R3, R4\n"
                "BNE     sub_FFD2AB98\n"
                "LDR     R6, =0x646F8\n"
                "LDR     R3, [R6]\n"
                "CMP     R3, #1\n"
                "BNE     sub_FFD2ABB4\n"
                "B       sub_FFD2AB9C\n"
	"sub_FFD2AB98:\n"
                "LDR     R6, =0x646F8\n"
	"sub_FFD2AB9C:\n"
                "LDR     R3, =0x64798\n"
                "MOV     R0, R4\n"
                "MOV     LR, PC\n"
                "LDR     PC, [R3]\n"
                "STR     R5, [R6]\n"
                "STR     R4, [R7]\n"
	"sub_FFD2ABB4:\n"
                "LDR     R2, =0x646F4\n"
                "MOV     R3, #0\n"
                "STR     R3, [R2]\n"
	"sub_FFD2ABC0:\n"
                "ADD     SP, SP, #0x34\n"
                "LDMFD   SP!, {R4-R11,PC}\n"
	);
}



void __attribute__((naked,noinline)) sub_FFD2C0D0_my(){
	asm volatile(
                "STMFD   SP!, {R4-R11,LR}\n"
                "LDR     R5, =0x64A5C\n"
                "SUB     SP, SP, #0x14\n"
                "LDR     LR, [R5]\n"
                "LDR     R12, =0x64A74\n"
                "ADD     LR, LR, #1\n"
                "LDR     R4, [R12]\n"
                "STR     LR, [R5]\n"
                "LDR     R12, =0x64AF4\n"
                "STR     R0, [SP,#0x10]\n"
                "STR     R1, [SP,#0xC]\n"
                "STR     R2, [SP,#0x8]\n"
                "STR     R3, [SP,#0x4]\n"
                "CMP     LR, R4\n"
                "LDR     R11, [R12]\n"
                "MOVHI   R0, #0x80000001\n"
                "BHI     sub_FFD2C5B8\n"
                "LDR     R3, =0x64AD8\n"
                "MOV     R0, LR\n"
                "LDR     R1, [R3]\n"
                "BL      sub_FFEBF7F4\n"
                "CMP     R0, #1\n"
                "BNE     sub_FFD2C2F0\n"
                "LDR     R0, =0x64AFC\n"
                "LDR     R1, =0x64A48\n"
                "LDR     R3, [R0]\n"
                "LDR     R2, [R1]\n"
                "CMP     R3, R2\n"
                "LDREQ   R3, =0x64AF8\n"
                "LDREQ   R5, [R3]\n"
                "MOVNE   R5, R2\n"
                "LDR     R3, =0x64A5C\n"
                "LDR     R2, =0x64AD8\n"
                "LDR     R0, [R3]\n"
                "LDR     R1, [R2]\n"
                "BL      sub_FFEBF164\n"
                "LDR     R3, =0x64A50\n"
                "ADD     R0, R0, #1\n"
                "AND     R0, R0, #1\n"
                "STR     R5, [R3,R0,LSL#2]\n"
                "LDR     R3, =0x64A44\n"
                "LDR     R2, [R3]\n"
                "CMP     R5, R2\n"
                "BHI     sub_FFD2C1A0\n"
                "LDR     R4, =0x64A94\n"
                "LDR     R3, [R4]\n"
                "ADD     R3, R5, R3\n"
                "ADD     R3, R3, #8\n"
                "CMP     R2, R3\n"
                "BCS     sub_FFD2C1A4\n"
"sub_FFD2C198:\n"
                "MOV     R0, #0x80000003\n"
                "B       sub_FFD2C5B8\n"
"sub_FFD2C1A0:\n"
                "LDR     R4, =0x64A94\n"
"sub_FFD2C1A4:\n"
                "LDR     R3, [R4]\n"
                "LDR     R2, =0x64AFC\n"
                "ADD     R1, R5, R3\n"
                "LDR     R3, [R2]\n"
                "ADD     R2, R1, #8\n"
                "CMP     R2, R3\n"
                "BLS     sub_FFD2C1F0\n"
                "LDR     R2, =0x64AF8\n"
                "LDR     R0, =0x64A44\n"
                "RSB     R3, R3, R1\n"
                "LDR     R1, [R2]\n"
                "ADD     R3, R3, #8\n"
                "LDR     R2, [R0]\n"
                "ADD     R1, R1, R3\n"
                "CMP     R2, R1\n"
                "BCC     sub_FFD2C198\n"
                "LDR     R3, =0x64A48\n"
                "STR     R1, [R3]\n"
                "B       sub_FFD2C1F8\n"
"sub_FFD2C1F0:\n"
                "LDR     R3, =0x64A48\n"
                "STR     R2, [R3]\n"
"sub_FFD2C1F8:\n"
                "LDR     R3, [R4]\n"
                "LDR     R12, =0x64AA8\n"
                "ADD     R3, R3, #0x18\n"
                "LDR     R2, [R12,#4]\n"
                "MOV     R0, R3\n"
                "MOV     R1, #0\n"
                "CMP     R1, R2\n"
                "BHI     sub_FFD2C43C\n"
                "BNE     sub_FFD2C228\n"
                "LDR     R3, [R12]\n"
                "CMP     R0, R3\n"
                "BHI     sub_FFD2C43C\n"
"sub_FFD2C228:\n"
                "LDR     R4, [R4]\n"
                "LDR     LR, =0x64AB0\n"
                "STR     R4, [SP,#0x38-0x38]\n"
                "LDR     R12, =0x64AA8\n"
                "LDR     R3, =0x64A5C\n"
                "LDMIA   LR, {R7,R8}\n"
                "LDMIA   R12, {R5,R6}\n"
                "LDR     R10, [R3]\n"
                "LDR     R2, =0x64AD8\n"
                "MOV     R3, R4\n"
                "MOV     R4, #0\n"
                "ADDS    R7, R7, R3\n"
                "ADC     R8, R8, R4\n"
                "LDR     R9, [R2]\n"
                "SUBS    R5, R5, R3\n"
                "SBC     R6, R6, R4\n"
                //"MOVL    R2, 0xFFFFFFFF\n"	//MOVL
                //"MOVL    R1, 0xFFFFFFE8\n"	//MOVL
		"MVN    R2, #0\n"	//MOVL
                "MVN    R1, #0x17\n"	//MOVL
                "ADDS    R5, R5, R1\n"
                "MOV     R4, #0\n"
                "MOV     R3, #0x18\n"
                "ADC     R6, R6, R2\n"
                "ADDS    R7, R7, R3\n"
                "ADC     R8, R8, R4\n"
                "STMIA   R12, {R5,R6}\n"
                "SUB     R0, R10, #1\n"
                "MOV     R1, R9\n"
                "STMIA   LR, {R7,R8}\n"
                "BL      sub_FFEBF164\n"
                "CMP     R10, #1\n"
                "MLA     R0, R9, R0, R0\n"
                "BEQ     sub_FFD2C2F0\n"
                "SUB     R3, R0, #1\n"
                "MOV     R3, R3,LSL#4\n"
                "ADD     R4, R11, #0x10\n"
                "ADD     R5, R11, #0x14\n"
                "LDR     R1, [R5,R3]\n"
                "LDR     R2, [R4,R3]\n"
                "LDR     LR, =0x62773130\n"
                "ADD     R2, R2, R1\n"
                "MOV     R3, R0,LSL#4\n"
                "ADD     R2, R2, #8\n"
                "MOV     R0, #0\n"
                "ADD     R12, R11, #0xC\n"
                "ADD     R1, R11, #8\n"
                "STR     LR, [R1,R3]\n"
                "STR     R0, [R12,R3]\n"
                "STR     R2, [R4,R3]\n"
                "LDR     R0, [SP,#0x38-0x38]\n"
                "STR     R0, [R5,R3]\n"
"sub_FFD2C2F0:\n"
                "LDR     R2, =0x64A48\n"
                "LDR     R3, =0x64AFC\n"
                "LDR     R1, [R2]\n"
                "LDR     R0, [R3]\n"
                "ADD     R3, R1, #9\n"
                "CMP     R3, R0\n"
                "BLS     sub_FFD2C32C\n"
                "LDR     R2, =0x64AF8\n"
                "LDR     R3, [R2]\n"
                "ADD     R3, R3, R1\n"
                "RSB     R3, R0, R3\n"
                "LDR     R0, [SP,#0x10]\n"
                "ADD     R3, R3, #8\n"
                "STR     R3, [R0]\n"
                "B       sub_FFD2C338\n"
"sub_FFD2C32C:\n"
                "ADD     R3, R1, #8\n"
                "LDR     R1, [SP,#0x10]\n"
                "STR     R3, [R1]\n"
"sub_FFD2C338:\n"
                "LDR     R2, [SP,#0x10]\n"
                "LDR     R1, =0x64AA4\n"
                "LDR     R3, =0x64AFC\n"
                "LDR     R12, [R2]\n"
                "LDR     R2, [R1]\n"
                "LDR     R0, [R3]\n"
                "ADD     R3, R12, R2\n"
                "CMP     R3, R0\n"
                "BLS     sub_FFD2C38C\n"
                "LDR     R2, [SP,#0xC]\n"
                "RSB     R0, R12, R0\n"
                "STR     R0, [R2]\n"
                "LDR     R2, =0x64AF8\n"
                "LDR     R3, [R1]\n"
                "LDR     R1, [R2]\n"
                "RSB     R3, R0, R3\n"
                "LDR     R0, [SP,#0x8]\n"
                "STR     R1, [R0]\n"
                "LDR     R1, [SP,#0x4]\n"
                "STR     R3, [R1]\n"
                "B       sub_FFD2C3A8\n"
"sub_FFD2C38C:\n"
                "LDR     R0, [SP,#0xC]\n"
                "STR     R2, [R0]\n"
                "LDR     R1, [SP,#0x4]\n"
                "MOV     R3, #0\n"
                "STR     R3, [R1]\n"
                "LDR     R2, [SP,#0x8]\n"
                "STR     R3, [R2]\n"
"sub_FFD2C3A8:\n"
                "LDR     R0, =0x64A48\n"
                "LDR     R1, =0x64A44\n"
                "LDR     R3, [R0]\n"
                "LDR     R2, [R1]\n"
                "CMP     R3, R2\n"
                "BHI     sub_FFD2C3D4\n"
                "LDR     R0, [SP,#0xC]\n"
                "LDR     R3, [R0]\n"
                "ADD     R3, R12, R3\n"
                "CMP     R2, R3\n"
                "BCC     sub_FFD2C198\n"
"sub_FFD2C3D4:\n"
                "LDR     R1, [SP,#0x8]\n"
                "LDR     R2, [R1]\n"
                "CMP     R2, #0\n"
                "BEQ     sub_FFD2C408\n"
                "LDR     R3, =0x64A44\n"
                "LDR     R1, [R3]\n"
                "CMP     R2, R1\n"
                "BHI     sub_FFD2C408\n"
                "LDR     R0, [SP,#0x4]\n"
                "LDR     R3, [R0]\n"
                "ADD     R3, R2, R3\n"
                "CMP     R1, R3\n"
                "BCC     sub_FFD2C198\n"
"sub_FFD2C408:\n"
                "LDR     R3, =0x64AA4\n"
                "LDR     R0, =0x64AA8\n"
                "LDR     R2, [R3]\n"
                "LDR     R3, [R0,#4]\n"
                "ADD     R2, R2, #0x18\n"
                "MOV     R1, R2\n"
                "MOV     R2, #0\n"
                "CMP     R2, R3\n"
                "BHI     sub_FFD2C43C\n"
                "BNE     sub_FFD2C444\n"
                "LDR     R3, [R0]\n"
                "CMP     R1, R3\n"
                "BLS     sub_FFD2C444\n"
"sub_FFD2C43C:\n"
                "MOV     R0, #0x80000005\n"
                "B       sub_FFD2C5B8\n"
"sub_FFD2C444:\n"
                "LDR     R1, =0x64A8C\n"
                "LDR     R0, =0x64AD8\n"
                "LDR     R3, [R1]\n"
                "LDR     R2, [R0]\n"
                "ADD     R3, R3, R2,LSL#4\n"
                "ADD     R3, R3, R3,LSL#2\n"
                "LDR     R12, =0x64AA8\n"
                "MOV     R3, R3,LSL#1\n"
                "ADD     R3, R3, #0xA0\n"
                "LDR     R2, [R12,#4]\n"
                "MOV     R0, R3\n"
                "MOV     R1, #0\n"
                "CMP     R1, R2\n"
                "BHI     sub_FFD2C48C\n"
                "BNE     sub_FFD2C4B0\n"
                "LDR     R3, [R12]\n"
                "CMP     R0, R3\n"
                "BLS     sub_FFD2C4B0\n"
"sub_FFD2C48C:\n"
                "LDR     R4, =0x64AC0\n"
                "LDR     R1, [R4]\n"
                "CMP     R1, #0\n"
                "BNE     sub_FFD2C4B0\n"
                "MOV     R0, #0x3140\n"			//MOVL
                "ADD     R0, R0, #8\n"
                "BL      sub_FFD43D9C\n"
                "MOV     R3, #1\n"
                "STR     R3, [R4]\n"
"sub_FFD2C4B0:\n"
                "LDR     R1, =0x64A8C\n"
                "LDR     R0, =0x64AD8\n"
                "LDR     R2, [R1]\n"
                "LDR     R3, [R0]\n"
                "LDR     R0, =0x64AB0\n"
                "ADD     R2, R2, R3,LSL#4\n"
                //"MOVL    R3, 0xFFFFFF60\n"		//MOVL------
		"MVN    R3, #0x9F\n"		//MOVL------
                "ADD     R2, R2, R2,LSL#2\n"
                "ADD     R3, R3, #0x40000000\n"
                "SUB     R3, R3, R2,LSL#1\n"
                "LDR     R1, [R0,#4]\n"
                "MOV     R4, R3\n"
                "MOV     R5, #0\n"
                "CMP     R1, R5\n"
                "BHI     sub_FFD2C4FC\n"
                "BNE     sub_FFD2C520\n"
                "LDR     R3, [R0]\n"
                "CMP     R3, R4\n"
                "BLS     sub_FFD2C520\n"
"sub_FFD2C4FC:\n"
                "LDR     R4, =0x64AC0\n"
                "LDR     R1, [R4]\n"
                "CMP     R1, #0\n"
                "BNE     sub_FFD2C520\n"
                "MOV     R0, #0x3140\n"			//MOVL
                "ADD     R0, R0, #8\n"
                "BL      sub_FFD43D9C\n"
                "MOV     R3, #1\n"
                "STR     R3, [R4]\n"
"sub_FFD2C520:\n"
                "LDR     R3, =0x64AD8\n"
                "LDR     R0, =0x64A74\n"
                "LDR     R2, [R3]\n"
                "LDR     R12, =0x64A5C\n"
                "LDR     R1, [R0]\n"
                "ADD     R3, R2, R2,LSL#2\n"
                "ADD     R2, R2, R3,LSL#1\n"
                "LDR     R0, [R12]\n"
                "RSB     R1, R2, R1\n"
                "CMP     R0, R1\n"
                "BLS     sub_FFD2C570\n"
                "LDR     R4, =0x64AC0\n"
                "LDR     R1, [R4]\n"
                "CMP     R1, #0\n"
                "BNE     sub_FFD2C570\n"
                "MOV     R0, #0x3140\n"			//MOVL
                "ADD     R0, R0, #8\n"
                "BL      sub_FFD43D9C\n"
                "MOV     R3, #1\n"
                "STR     R3, [R4]\n"
"sub_FFD2C570:\n"
                "LDR     R3, =0x64AB0\n"
                "LDR     R12, =0x64AA4\n"
                "LDMIA   R3, {R1,R2}\n"
                "LDR     R0, [R12]\n"
                "MOV     R4, #0\n"
                "MOV     R3, #0x18\n"
                "ADDS    R1, R1, R0\n"
                "ADC     R2, R2, #0\n"
                "ADDS    R1, R1, R3\n"
                "ADC     R2, R2, R4\n"
                "CMP     R2, #0\n"
                "BHI     sub_FFD2C5AC\n"
                "BNE     sub_FFD2C5B4\n"
                "CMP     R1, #0x40000000\n"
//                "BLS     sub_FFD2C5B4\n"	//-
		"B     sub_FFD2C5B4\n"	//+

"sub_FFD2C5AC:\n"
                "MOV     R0, #0x80000007\n"
                "B       sub_FFD2C5B8\n"
"sub_FFD2C5B4:\n"
                "MOV     R0, #0\n"
"sub_FFD2C5B8:\n"
                "ADD     SP, SP, #0x14\n"
                "LDMFD   SP!, {R4-R11,PC}\n"
	);
}



void __attribute__((naked,noinline)) sub_FFD2B4C0_my(){
	asm volatile(
                "CMP     R2, #1\n"
                "STMFD   SP!, {R4-R7,LR}\n"
                "MOV     R7, R0\n"
                "MOV     R6, R1\n"
                "MOVEQ   R3, #0x79\n"
                "STREQ   R3, [R6]\n"
                "LDMEQFD SP!, {R4-R7,PC}\n"
                "LDR     R12, =0x647C0\n"
                "LDR     R0, [R12]\n"
                "LDR     R3, =0x647C8\n"
                "CMP     R0, #0\n"
                "LDR     R1, [R3]\n"
                "BEQ     sub_FFD2B508\n"
                "LDR     R2, =0x647CC\n"
                "LDR     R3, [R2]\n"
                "CMP     R3, #1\n"
                "BNE     sub_FFD2B51C\n"
                "B       sub_FFD2B50C\n"  
"sub_FFD2B508:\n"
                "LDR     R2, =0x647CC\n"
"sub_FFD2B50C:\n"
                "MOV     R3, #0\n"
                "STR     R3, [R2]\n"
                "STR     R7, [R12]\n"
                "B       sub_FFD2B5D4\n"
"sub_FFD2B51C:\n"
                "LDR     R2, =0x647C4\n"
                "LDR     R3, [R2]\n"
                "LDR     R5, =table1\n"		//+ 0xFFD2B330
                "ADD     R3, R3, R3,LSL#1\n"
                "MOV     LR, R3,LSL#2\n"
                "LDR     R2, [R5,LR]\n"
                "LDR     R4, =table2\n"		//+ oxFFD2B354
                "RSB     R12, R2, R0\n"
                "LDR     R3, [R4,LR]\n"
                "CMP     R12, #0\n"
                "RSB     R0, R3, R0\n"
                "BLE     sub_FFD2B580\n"
                "ADD     R3, R5, #4\n"
                "LDR     R2, [R3,LR]\n"
                "CMP     R2, R12\n"
                "ADDGE   R1, R1, #1\n"
                "BGE     sub_FFD2B574\n"
                "ADD     R3, R5, #8\n"
                "LDR     R2, [R3,LR]\n"
                "CMP     R2, R12\n"
                "ADDGE   R1, R1, #2\n"
                "ADDLT   R1, R1, #3\n"
"sub_FFD2B574:\n"
//                "CMP     R1, #0xE\n"	//-
//                "MOVGE   R1, #0xE\n"	//-

                "CMP     R1, #0x1A\n"	//+
                "MOVGE   R1, #0x1A\n"	//+

                "B       sub_FFD2B5B8\n"
"sub_FFD2B580:\n"
                "CMP     R0, #0\n"
                "BGE     sub_FFD2B5B8\n"
                "ADD     R3, R4, #4\n"
                "LDR     R2, [R3,LR]\n"
                "CMP     R2, R0\n"
                "SUBLE   R1, R1, #1\n"
                "BLE     sub_FFD2B5B0\n"
                "ADD     R3, R4, #8\n"
                "LDR     R2, [R3,LR]\n"
                "CMP     R2, R0\n"
                "SUBLE   R1, R1, #2\n"
                "SUBGT   R1, R1, #3\n"
"sub_FFD2B5B0:\n"
                "CMP     R1, #0\n"
                "MOVLT   R1, #0\n"
"sub_FFD2B5B8:\n"
                "LDR     R0, =0x647C8\n"
                "LDR     R3, [R0]\n"
                "CMP     R1, R3\n"
                "LDRNE   R2, =0x647CC\n"
                "MOVNE   R3, #1\n"
                "STRNE   R1, [R0]\n"
                "STRNE   R3, [R2]\n"
"sub_FFD2B5D4:\n"
                "LDR     R3, =0x647C8\n"
//                "LDR     R1, =0x60E4\n"	//-
                "LDR     R1, =video_mode\n"	//+
                "LDR     R0, [R3]\n"
                "LDR     R2, =CompressionRateTable\n"	//+ 0xFFD2B2F4
                "LDR     R12, [R1]\n"
		"LDR     R12, [R12]\n"		//+
                "LDR     LR, [R2,R0,LSL#2]\n"
                "LDR     R3, =0x647C0\n"
                "CMP     R12, #1\n"
                "STR     R7, [R3]\n"
                "STR     LR, [R6]\n"
//                "MOVEQ   R3, #0xB\n"		//-

                "LDREQ   R3, =video_quality\n"   // +
                "LDREQ   R3, [R3]\n"             // +
                "LDREQ   R3, [R3]\n"             // +

                "STREQ   R3, [R6]\n"
                "BL      mute_on_zoom\n"     // +
                "LDMFD   SP!, {R4-R7,PC}\n"
	);
}
